import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/login',
    component: _ => import('@/views/Login')
  },
  {
    path: '/layout',
    component: _ => import('@/views/Layout'),
    children: [
      {
        path: '',
        component: _ => import('@/views/Home')
      },
      {
        path: '/qa',
        component: _ => import('@/views/QA')
      },
      {
        path: '/video',
        component: _ => import('@/views/Video')
      },
      {
        path: '/profile',
        component: _ => import('@/views/Profile')
      }
    ]
  },
  {
    path: '/search',
    component: _ => import('@/views/Search')
  },
  {
    path: '/article/:articleId',
    name: 'article', // 指定name
    component: _ => import('@/views/Article'),
    props: true //  开启props传参
  }
]

const router = new VueRouter({
  routes
})

export default router
